package com.gem.mapper;

import com.gem.entity.Admin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AdminMapper {
    //根据aid查询
    @Select("select * from tb_admin where aid=#{param1}")
    Admin selectById(Integer aid);

    //根据用户名和密码查询
    @Select("select * from tb_admin where aname=#{param1} and apassword=#{param2}")
    Admin selectByAnameAndApassword(String aname,String apassword);

    //查询全部
    @Select("select * from tb_admin")
    List<Admin> selectAll();

    //添加
    @Insert("insert into tb_admin values(null,#{aname},#{apassword})")
    boolean insert(Admin admin);

    //根据aid修改用户名和密码
    @Update("update tb_admin set aname=#{aname},apassword=#{apassword} where aid=#{aid}")
    boolean update(Admin admin);

    //根据aid删除
    @Delete("delete from tb_admin where aid=#{param1}")
    boolean deleteById(Integer aid);
}
